<?php

namespace app\sample_rsv\model;
use think\Exception;
use think\exception\PDOException;
use think\Model;

class Sample extends Model
{
    //样品状态
    public function setSampleStatusAttr($value)
    {
        $arr_status=[
        	0=>'待检',
        	1=>'在检',
        	2=>'已检',
    	];
        if (!in_array($value,$arr_status)) throw new Exception('SampleStatus非法');
        return $arr_status[$value];
    }

    //检材类型
    public function setIdSampleTypeAttr($value)
    {
        if (!SampleType::get($value)) throw new Exception('SampleType非法');
        return $value;
    }

    //保存位置
    public function setIdStorePositionAttr($value)
    {
        if (!StorePosition::get($value)) throw new Exception('StorePosition非法');
        return $value;
    }

    //所属委托
    public function setIdGroupAttr($value)
    {
        if (!Group::get($value)) throw new Exception('Group非法');
        return $value;
    }    

}